// 引入驱动模块
const mongoose = require('mongoose')
// mongodb连接
mongoose.connect(
    "mongodb://root:root@localhost:27017/shop?authSource=admin",{
        // "mongodb://localhost:27017/shop",{
    useNewUrlParser:true,
    useUnifiedTopology: true
})
const db=mongoose.connection
// 监听数据库连接成功
db.on('open',()=>console.log('数据库连接成功'))
// 监听数据库连接失败
db.on('error',()=>console.log('数据库连接失败'))

// 将mongoose导出
module.exports = mongoose